
/* 取地址 */
pub fn key_index(bytes:&[u8], start_index: usize) -> Option<u32> {
    if bytes.len() < start_index + 3 {
        return None;
    }
    Some((bytes[start_index] as u32) << 16 | (bytes[start_index + 1] as u32) << 8 | (bytes[start_index + 2] as u32))
}


/* 换位 */
pub fn swap(bytes: &mut [u8]){
    for i in 0..bytes.len() {
        let b1 = bytes[i];
        bytes[i] = ((b1 & 0x0f) << 4) | ((b1 & 0xf0) >> 4);
    }
}


/// 对两个 &[u8] 数组进行逐元素的按位异或操作
fn xor_arrays(a: &[u8], b: &[u8]) -> Vec<u8> {
    if a.len() != b.len() {
        panic!("Arrays must be of the same length");
    }
    a.iter().zip(b.iter()).map(|(&x, &y)| x ^ y).collect()
}










